(function (global, factory) {
  if (typeof define === "function" && define.amd) {
    define(['exports'], factory);
  } else if (typeof exports !== "undefined") {
    factory(exports);
  } else {
    var mod = {
      exports: {}
    };
    factory(mod.exports);
    global.util = mod.exports;
  }
})(this, function (exports) {
  'use strict';

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  var Util = function ($) {

    var transition = false;

    var TransitionEndEvent = {
      WebkitTransition: 'webkitTransitionEnd',
      MozTransition: 'transitionEnd',
      OTransition: 'oTransitionEnd otransitionend',
      transition: 'transitionend'
    };

    function transitionEndTest() {
      var el = document.createElement('fancy');

      for (var name in TransitionEndEvent) {
        if (el.style[name] !== undefined) {
          return { end: TransitionEndEvent[name] };
        }
      }
      return false;
    }

    function transitionEndEmulator(duration) {
      var _this = this;

      var called = false;

      $(this).one(transition.end, function () {
        called = true;
      });

      setTimeout(function () {
        if (!called) {
          Util.triggerTransitionEnd(_this);
        }
      }, duration);
    }

    function setTransitionEndSupport() {
      transition = transitionEndTest();
      $.fn.emulateTransitionEnd = transitionEndEmulator;
    }

    var Util = {
      transitionEnd: function transitionEnd() {
        return transition.end;
      },
      reflow: function reflow(element) {
        new Function('fa', 'return fa')(element.offsetHeight);
      },
      supportTransitionEnd: function supportTransitionEnd() {
        return Boolean(transition);
      },
      triggerTransitionEnd: function triggerTransitionEnd(element) {
        $(element).trigger(transition.end);
      }
    };

    setTransitionEndSupport();

    return Util;
  }(Zepto || jQuery);

  exports.default = Util;
});